﻿/**
 * Created by TX on 2016/9/27
 * version: 3.0.4
 */
console.log("UC3.0.5 say hello ");

// 封装

(function (global, factory) {
    typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
        typeof define === 'function' && define.amd ? define( ["jquery"], factory):
            (global.uc305 = factory());
}(this, function () {
    // 'use strict';
    /**********************配置  Start************************/

    var config = {
        //DeBug
        DeBug: true,
        //显示调用地址(除Query)
        ShowURL: true,
        //显示Query接口返回事件(有事件的情况下)
        ShowQuery: true,
        //Query接口调用间隔(毫秒)
        QueryTime: 1000
    }

    /**********************配置 End************************/

    /**********************数据获取类接口  Start************************/

// 获取事件的HttpServer地址
    var httpServerAdress = "http://127.0.0.1:9009/State/query?webcallType=callBar&";
// 坐席随路数据接口
    var httpServerAdressSetAssociate = "http://127.0.0.1:9009/CallControl/SetAssociateData?webcallType=callBar&";

    /**********************数据获取类接口 End************************/

    /**********************话务控制类接口  Start************************/

//1 初始化
    var httpServerAdressInitialize = "http://127.0.0.1:9009/Agent/Initialize?webcallType=callBar&";
//2 登陆
    var httpServerAdressLogin = "http://127.0.0.1:9009/Agent/Login?webcallType=callBar&";
//3 反初始化
    var httpServerAdressUnInitialize = "http://127.0.0.1:9009/Agent/UnInitialize?webcallType=callBar&";
//4 坐席登出
    var httpServerAdressLogOut = "http://127.0.0.1:9009/Agent/Logout?webcallType=callBar&";
//5 外呼
    var httpServerAdressCallOut = "http://127.0.0.1:9009/CallControl/MakeCall?webcallType=callBar&";
//6 置闲
    var httpServerAdressReady = "http://127.0.0.1:9009/State/Ready?webcallType=callBar&";
//7 置忙
    var httpServerAdressNotReady = "http://127.0.0.1:9009/State/NotReady?webcallType=callBar&";
//8 挂断
    var httpServerAdressDisconnect = "Http://127.0.0.1:9009/CallControl/Hangup?webcallType=callBar&";
//9 咨询地址
    var httpServerAdressConsulting = "http://127.0.0.1:9009/CallControl/Consult?webcallType=callBar&";
//10 转移
    var httpServerAdressShift = "http://127.0.0.1:9009/CallControl/Transfer?webcallType=callBar&";
//11 保持
    var httpServerAdressHold = "http://127.0.0.1:9009/CallControl/Hold?webcallType=callBar&";
//12 会议
    var httpServerAdressMeeting = "http://127.0.0.1:9009/CallControl/Conference?webcallType=callBar&";
//13 接听
    var httpServerAdressAnswer = "http://127.0.0.1:9009/CallControl/Answer?webcallType=callBar&";
//14 坐席协作接口
    var httpServerAdressAgentCooperation = "http://127.0.0.1:9009/CallControl/AssistIVRService?webcallType=callBar&";
//15 接回
    var httpServerAdressRetrive = "http://127.0.0.1:9009/CallControl/Retrive?webcallType=callBar&";
//16 满意度
    var httpServerAdressSatisfaction = "http://127.0.0.1:9009/State/Satisfaction?webcallType=callBar&";
//17 重置
    var httpServerAdressReset = "http://127.0.0.1:9009/CallControl/Reset?webcallType=callBar&";
//18 获取上一次事件
    var httpServerAdressGetlastEvent = "http://127.0.0.1:9009/Agent/GetlastEvent?webcallType=callBar&";
//19 获取人员列表
    var httpServerAdressGetAgent = "http://127.0.0.1:9009/Agent/GetAgent?webcallType=callBar&";
//20 强插接口地址
    var httpServerInsert = "http://127.0.0.1:9009/CallControl/Intrude?webcallType=callBar&";
//21 强拆接口地址
    var httpServerDrop = "http://127.0.0.1:9009/CallControl/DropAll?webcallType=callBar&";
//22 监听接口地址
    var httpServerListen = "http://127.0.0.1:9009/CallControl/SilentMonitor?webcallType=callBar&";
//23 获取配置文件中的设置项
    var httpServerGetConfig = "http://127.0.0.1:9009/Config/Getconfig?webcallType=callBar&";
//24 设置配置文件中的设置项
    var httpServerSetConfig = "http://127.0.0.1:9009/Config/Setconfig?webcallType=callBar&";
//25 发送按键
    var httpServerSendDTMF = "http://127.0.0.1:9009/CallControl/SendDTMF?webcallType=callBar&";
//26 会议强拆坐席
    var httpServerHeadoff = "http://127.0.0.1:9009/CallControl/Headoff?webcallType=callBar&";
//27 设置其他业务系统获取事件识别码
    var httpServerSetPageIndex = "http://127.0.0.1:9009/State/setPageIndex?webcallType=callBar&";
//28 获取坐席登录信息
    var httpServerGetAgentLoginInfo = "http://127.0.0.1:9009/State/GetAgentLoginInfo?webcallType=callBar&";
//29 获取外显号
    var httpServerGetShowANI = "http://127.0.0.1:9009/AgentState/GetShowANI?webcallType=callBar&";
//30 获取号码归属地
    var httpServerGetNumBelong = "http://127.0.0.1:9009/State/GetNumBelonging?webcallType=callBar&"
//31 获取通时通次
    var httpServerGetCallReport = "http://127.0.0.1:9009/AgentState/GetCallReporting?webcallType=callBar&"
//32 获取随路数据
    var httpServerGetAssociateData = "http://127.0.0.1:9009/CallControl/GetAssociateData?webcallType=callBar&"
//33 新登录接口
    var httpServerAdressLoginEx = "http://127.0.0.1:9009/Agent/Loginex?webcallType=callBar&";
//34 获取坐席状态
    var httpServerGetAgentState = "http://127.0.0.1:9009/State/GetAgentState?webcallType=callBar&";
//35 密语
  var httpServerAdressWhisper = "http://127.0.0.1:9009/CallControl/Whisper?webcallType=callBar&";
// 2021-02-21 转接IVR追加start
//36 转IVR
var httpServerAdressToIVR = "http://127.0.0.1:9009/CallControl/ToIVR?webcallType=callBar&";
//36 转接技能组
var httpServerAdressTransferSkill = "http://127.0.0.1:9009/CallControl/TransgerSkills?webcallType=callBar&";
//37 获取技能组列表
var httpServerAdressGetSkillList = "http://127.0.0.1:9009/CallControl/GetSkills?webcallType=callBar&";
//38 静音
var httpServerAdressSetMicMute = "http://127.0.0.1:9009/CallControl/SetMicMUTE?webcallType=callBar&"
// 2021-02-21 转接IVR追加end
    /**********************数据获取类接口 End************************/

    var openUrl = "http://www.huayunworld.com/";
// 弹屏方式
// UC_OPEN: UC直接弹屏
// CALL_BACK: UC回调弹屏
    var openWindowMode = "CALL_BACK";
// 刷新事件
//var refreshTime = 100;

    /************************操作类型 Start************************/

    var operation_type = new Array();
// 外呼
    operation_type[0] = "CallOut";
// 置闲
    operation_type[1] = "Ready";
// 置忙
    operation_type[2] = "NotReady";
// 挂断
    operation_type[3] = "Disconnect";
// 坐席协作
    operation_type[4] = "Cooperation";
// 接回
    operation_type[5] = "Retrive";

    /************************操作类型 End************************/

    /************************参数列表 Start************************/
    var call_in_params = new Array();
// 原始主叫
    call_in_params[0] = "OrgANI";
// 原始被叫
    call_in_params[1] = "OrgDNIS";
// 当前主叫
    call_in_params[2] = "ANI";
// 当前被叫
    call_in_params[3] = "DNIS";
// 咨询主叫
    call_in_params[4] = "CslANI";
// 咨询被叫
    call_in_params[5] = "CslDNIS";
// 服务类型
    call_in_params[6] = "ServiceUnitType";
// 请求技能组
    call_in_params[7] = "ReqSkill";
// 响应技能组
    call_in_params[8] = "ResSkill";
// 呼叫类型
    call_in_params[9] = "CallType";
// 本次呼叫标识
    call_in_params[10] = "SessionID";
// IVR数据
    call_in_params[11] = "IVRData";

    /************************参数列表 End************************/

// http请求方式
    var requestType = "get";

    var prefix = "";

    /**********************返回结果定义 Start************************/

// 事件类型
    var EventType = "EventType";
// 原始主叫
    var OrgANI = "OrgANI";
// 原始被叫
    var OrgDNIS = "OrgDNIS";
// 当前主叫
    var ANI = "ANI";
// 当前被叫
    var DNIS = "DNIS";
// 咨询主叫
    var CslANI = "CslANI";
// 咨询被叫
    var CslDNIS = "CslDNIS";
// 服务类型
    var ServiceUnitType = "ServiceUnitType";
// 请求技能组
    var ReqSkill = "ReqSkill";
// 响应技能组
    var ResSkill = "ResSkill";
// 呼叫类型
    var CallType = "CallType";
// IVR数据
    var IVRData = "IVRData";
// 本次呼叫表示
    var SessionID = "SessionID";
// 坐席工号
    var agentID = "";
// 坐席分机
    var deviceID = "";

    var m_PageIndex = guid();
    var referer = "";

    /**********************返回结果定义 End************************/

    /**********************事件类型EventType Start************************/

// Init状态
    var AgentStatus_Init = "AgentStatus_Init";
// Login状态
    var AgentStatus_Login = "AgentStatus_Login";
// Logout状态
    var AgentStatus_Logout = "AgentStatus_Logout";
// Ready状态
    var AgentStatus_Ready = "AgentStatus_Ready";
// NotReady状态
    var AgentStatus_NotReady = "AgentStatus_NotReady";
// Otherwork状态
    var AgentStatus_Otherwork = "AgentStatus_Otherwork";
// ACW状态
    var AgentStatus_ACW = "AgentStatus_ACW";
// Locked状态
    var AgentStatus_Locked = "AgentStatus_Locked";
// Alerting状态
    var AgentStatus_Alerting = "AgentStatus_Alerting";
// Connecting状态
    var AgentStatus_Connecting = "AgentStatus_Connecting";
// Connected_Normal状态
    var AgentStatus_Connected_Normal = "AgentStatus_Connected_Normal";
// Connected_Internal状态
    var AgentStatus_Connected_Internal = "AgentStatus_Connected_Internal";
// Disconnected状态
    var AgentStatus_Disconnected = "AgentStatus_Disconnected";
// Suspended状态
    var AgentStatus_Suspended = "AgentStatus_Suspended";
// Held状态(请求IVR服务时转为此状态)
    var AgentStatus_Held = "AgentStatus_Held";
// Consulting状态
    var AgentStatus_Consulting = "AgentStatus_Consulting";
// Consulted状态
    var AgentStatus_Consulted = "AgentStatus_Consulted";
// Conferenced状态
    var AgentStatus_Conferenced = "AgentStatus_Conferenced";
// Monitored状态
    var AgentStatus_Monitored = "AgentStatus_Monitored";
// Inserted状态
    var AgentStatus_Inserted = "AgentStatus_Inserted";
// Unkown状态
    var AgentStatus_Unkown = "AgentStatus_Unkown";

    /**********************事件类型EventType End************************/

    /**********************呼叫类型 Start************************/

// 呼叫类型：
// 标识 信息 信息描述
// 0 INTERNAL 呼入
// 1 OUTBOUND 外呼
// 2 INBOUND 内呼
    var INTERNAL = "INTERNAL";
    var OUTBOUND = "OUTBOUND";
    var INBOUND = "INBOUND";

    var event_params = new Array();
// 原始主叫
    event_params[0] = OrgANI;
// 原始被叫
    event_params[1] = OrgDNIS;
// 当前主叫
    event_params[2] = ANI;
// 当前被叫
    event_params[3] = DNIS;
// 咨询主叫
    event_params[4] = CslANI;
// 咨询被叫
    event_params[5] = CslDNIS;
// 服务类型
    event_params[6] = ServiceUnitType;
// 请求技能组
    event_params[7] = ReqSkill;
// 响应技能组
    event_params[8] = ResSkill;
// 呼叫类型
    event_params[9] = CallType;
// 本次呼叫标识
    event_params[10] = SessionID;
// IVR数据
    event_params[11] = IVRData;

    /**********************呼叫类型 End************************/

    var ucwindows;
    var ucdocument;

    var handle;
    var thirdcode = '0';

    /* UCObj version 3.3 pre
     * creator: wu-tong (wutong@huayunwrold.com)
     * 最新更新：2018-8-7
     */
    function UCObj(win, doc) {

        ucwindows = win;
        ucdocument = doc;

        /*
         * 开始向UC取来电事件.每搁1000ms取一次
         */
        this.initUCObj = function (openURL, params, requestTime) {
            openUrl = openURL;
            call_in_params = params;
            config.QueryTime = (requestTime == null || requestTime == undefined) ? config.QueryTime : requestTime;
            //  var  refreshtime = 1000;
        }

        /*
         * 开始向UC取事件
         */
        this.start = function (callback_event) {
            handle = win.setInterval(function () {
                getEvent(callback_event); //振铃事件
            }, config.QueryTime);
        }

        // var w;
        // this.start = function (callback_event) {
        //    if (typeof (Worker) !== "undefined") {
        //        if (typeof (w) == "undefined") {
        //            // w = new Worker("./lib/web_worker.js");
        //            w = new Worker("./static/newPhone/lib/web_worker.js");
        //            w.onmessage = function (evt) {
        //                getEvent(callback_event); //振铃事件
        //            }
        //        }
        //        w.postMessage(true);
        //    } else {
        //        handle = win.setInterval(function () {
        //            getEvent(callback_event); //振铃事件
        //        }, config.QueryTime);
        //    }
        // }

        this.stopObj = function () {
            clearInterval(handle);
        }

        // this.stopObj = function () {
        //    if (typeof (Worker) !== "undefined") {
        //        if (typeof (w) !== "undefined") {
        //            w.postMessage(false);
        //        }
        //    } else {
        //        clearInterval(handle);
        //    }
        // }

        /*
        * 重置处理
        */
        this.doReset = function (callback) {

            jQuery.ajax({
                type: requestType,
                url: httpServerAdressReset,
                dataType: "jsonp",
                jsonp: "callback",
                beforeSend: function (XMLHttpRequest) {
                    _showMessage.showDebugMessage("调用本地“重置”接口开始");
                    _showMessage.showURLMessage("重置地址：" + httpServerAdressReset);
                },
                success: function (data) {
                    _showMessage.showDebugMessage("调用本地“重置”接口成功, Code: " + data.Code);
                    if (callback != undefined) {
                        callback(data)
                    }
                },
                complete: function (XMLHttpRequest, textStatus) {

                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    //请求出错处理
                    _showMessage.showDebugMessage("调用本地“重置”接口失败: \n" +
                        "XMLHttpRequest:" + XMLHttpRequest +
                        "\ntextStatus:" + textStatus +
                        "\nerrorThrown:" + errorThrown
                    );
                }
            })

            _showMessage.showDebugMessage("调用本地“重置”接口结束");
        }

        /*
        * 获取上一次事件
        */
        this.doGetlastEvent = function (callback) {

            jQuery.ajax({
                type: requestType,
                url: httpServerAdressGetlastEvent,
                dataType: "jsonp",
                jsonp: "callback",
                beforeSend: function (XMLHttpRequest) {
                    _showMessage.showDebugMessage("调用“获取上一次事件”接口开始");
                    _showMessage.showURLMessage("获取上一次事件地址：" + httpServerAdressGetlastEvent);
                },
                success: function (data) {
                    _showMessage.showDebugMessage("调用“获取上一次事件”接口成功, Code: " + data.Result);
                    if (callback != undefined) {
                        callback(data)
                    }
                },
                complete: function (XMLHttpRequest, textStatus) {

                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    //请求出错处理
                    _showMessage.showDebugMessage("调用“获取上一次事件”接口失败: \n" +
                        "XMLHttpRequest:" + XMLHttpRequest +
                        "\ntextStatus:" + textStatus +
                        "\nerrorThrown:" + errorThrown
                    );
                }
            })

            _showMessage.showDebugMessage("doGetlastEvent End..................");
        }

        /*
        * 坐席初始化-Initialize
        */
        this.doInitialize = function (SP_ServerIp, SP_ServerPort, SP_LocalIp, SP_LocalPort, entID, resourceNo, sipServer, sipPort, sipUser, sipPWD, terminalType, agentid, endpoint, agentPassWord,callback) {

            var initializeURL = httpServerAdressInitialize + "usIP=" + SP_ServerIp + "&usPort=" + SP_ServerPort + "&enterpriseID=" + entID + "&dnis=" + resourceNo + "&localIp=" + SP_LocalIp + "&usLocalPort=" + SP_LocalPort + "&SIPSERVERIP=" + sipServer + "&SIPSERVERPORT=" + sipPort + "&sipUsername=" + sipUser + "&sipPassword=" + sipPWD + "&TerminalType=" + terminalType + "&endpoint=" + endpoint + "&agentid=" + agentid + "&agentPassWord=" + agentPassWord + "&isDomain=false&isCompressed=false&callback=?";

            jQuery.ajax({
                async: false,
                type: requestType,
                url: initializeURL,
                dataType: "jsonp",
                jsonp: "callback",
                beforeSend: function (XMLHttpRequest) {
                    _showMessage.showDebugMessage("调用本地“初始化”接口开始");
                    _showMessage.showURLMessage("初始化地址：" + initializeURL);
                },
                success: function (data) {
                    _showMessage.showDebugMessage("调用本地“初始化”接口成功, Code: " + data.Code)
                    if (data.Code === "0") {
                        prefix = (terminalType == 2 || terminalType == 5) ? "sip:" : terminalType == 0 ? "tel:" : "";
                    }
                    if (data.Code === "-1") {
                        _showMessage.showDebugMessage('初始化失败，重新调用反初始化 初始化 登录接口');
                        doUnInitialize(window.doInitialize);
                    }
                    if (callback != undefined) {
                        callback(data);
                    }
                },
                complete: function (XMLHttpRequest, textStatus) {

                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    _showMessage.showDebugMessage("调用本地“初始化”接口失败:\n" +
                        "XMLHttpRequest:" + XMLHttpRequest +
                        "\ntextStatus:" + textStatus +
                        "\nerrorThrown:" + errorThrown
                    );

                }
            })
        }

        /*
        * 登录
        */
        this.login = function (agentId, agentName, agentPwd, agentIP, agentDN, agentSkillList, forcedLogin,endpoint, callback) {
            // 先进行 pass 初始化
            // 再进行 初始化（初始化 反初始化 初始化）

            var loginUrl = httpServerAdressLogin + "agentId=" + agentId + "&agentName=" + encodeURI(agentName) + "&AGENTPWD=" + agentPwd + "&AGENTIP=" + agentIP + "&agentDN=" + prefix + agentDN + "&SRVSKILLSDESC=" + encodeURI(agentSkillList) + "&forcedLogin=" + forcedLogin + "&endpoint=" + endpoint + "&callback=?";
            jQuery.ajax({
                async: false,
                type: requestType,
                url: loginUrl,
                dataType: "jsonp",
                jsonp: "callback",
                beforeSend: function (XMLHttpRequest) {
                    _showMessage.showDebugMessage("调用本地“登陆”接口开始");
                    _showMessage.showURLMessage("登录地址：" + loginUrl);
                },
                success: function (data) {
                    _showMessage.showDebugMessage("调用本地“登陆”接口成功, Code:" + data.Code);
                    if (callback != undefined) {
                        callback(data);
                    }
                },
                complete: function (XMLHttpRequest, textStatus) {

                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    //请求出错处理
                    _showMessage.showDebugMessage("调用本地“登陆”接口失败: \n" +
                        "XMLHttpRequest:" + XMLHttpRequest +
                        "\ntextStatus:" + textStatus +
                        "\nerrorThrown:" + errorThrown
                    );
                    //_showMessage.showDebugMessage("调用本地“登陆”接口失败: {\"XMLHttpRequest\":" + XMLHttpRequest + ",\"textStatus\":\"" + textStatus + "\",\"errorThrown\":\"" + errorThrown + "\" }");
                }
            })
            _showMessage.showDebugMessage("调用本地“登陆”接口完成");
        }

        this.loginex = function (LoginURL, agentId, agentPwd, EnterpriseID, agentDN, TerminalType, callback) {
            refix = (TerminalType == 2 || TerminalType == 5) ? "sip:" : TerminalType == 0 ? "tel:" : ""
            var loginUrl = httpServerAdressLoginEx + "agentId=" + agentId + "&AGENTPWD=" + agentPwd + "&EnterpriseID=" + EnterpriseID + "&agentDN=" + refix + agentDN + "&TerminalType=" + TerminalType + "&LoginURL=" + LoginURL + "&callback=?";
            jQuery.ajax({
                async: false,
                type: requestType,
                url: loginUrl,
                dataType: "jsonp",
                jsonp: "callback",
                beforeSend: function (XMLHttpRequest) {
                    _showMessage.showDebugMessage("调用本地“登陆”接口开始");
                    _showMessage.showURLMessage("登录地址：" + loginUrl);
                },
                success: function (data) {
                    _showMessage.showDebugMessage("调用本地“登陆”接口成功, Code:" + data.Code);
                    if (callback != undefined) {
                        callback(data);
                    }
                },
                complete: function (XMLHttpRequest, textStatus) {

                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    //请求出错处理
                    _showMessage.showDebugMessage("调用本地“登陆”接口失败: \n" +
                        "XMLHttpRequest:" + XMLHttpRequest +
                        "\ntextStatus:" + textStatus +
                        "\nerrorThrown:" + errorThrown
                    );
                    //_showMessage.showDebugMessage("调用本地“登陆”接口失败: {\"XMLHttpRequest\":" + XMLHttpRequest + ",\"textStatus\":\"" + textStatus + "\",\"errorThrown\":\"" + errorThrown + "\" }");
                }
            })
            _showMessage.showDebugMessage("调用本地“登陆”接口完成");
        }

        /*
        * 外呼处理
        */
        this.doCallOut = function (callNum, showNum, callback) {

            //外拨加Tel，或出局需加0
            if (callNum.indexOf('sip:') === -1) {
                callNum = "Tel:" + callNum;
             }
            var makeCallType = "&makecallType=2";
            var callOutUrl = httpServerAdressCallOut + "TARGETDN=" + callNum + makeCallType + "&showANI=" + showNum + "&type=1&callback=?";

            jQuery.ajax({
                type: requestType,
                url: callOutUrl,
                dataType: "jsonp",
                jsonp: "callback",
                beforeSend: function (XMLHttpRequest) {
                    _showMessage.showDebugMessage("调用本地“外呼”接口开始");
                    _showMessage.showURLMessage("外呼地址：" + callOutUrl);
                },
                success: function (data) {
                    //ucwindows.resultCallBack("doLogOut", data);
                    _showMessage.showDebugMessage("调用本地“外呼”接口成功, Code: " + data.Code);
                    if (callback!=undefined) {
                        callback(data);
                    }
                },
                complete: function (XMLHttpRequest, textStatus) {

                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    //请求出错处理
                    _showMessage.showDebugMessage("调用本地“外呼”接口失败 : \n" +
                        "XMLHttpRequest:" + XMLHttpRequest +
                        "\ntextStatus:" + textStatus +
                        "\nerrorThrown:" + errorThrown
                    );
                }
            })

            _showMessage.showDebugMessage("调用本地“外呼”接口结束");
        }

        /*
        * 置闲处理
        */
        this.doReady = function (callback) {

            jQuery.ajax({
                type: requestType,
                url: httpServerAdressReady,
                dataType: "jsonp",
                jsonp: "callback",
                beforeSend: function (XMLHttpRequest) {
                    _showMessage.showDebugMessage("调用本地“置闲”接口开始");
                    _showMessage.showURLMessage("置闲地址：" + httpServerAdressReady);
                },
                success: function (data) {
                    _showMessage.showDebugMessage("调用本地“置闲”接口成功, Code: " + data.Code);
                    if (callback != undefined) {
                        callback(data)
                    }
                },
                complete: function (XMLHttpRequest, textStatus) {

                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    _showMessage.showDebugMessage("调用本地“置闲”接口失败: \n" +
                        "XMLHttpRequest:" + XMLHttpRequest +
                        "\ntextStatus:" + textStatus +
                        "\nerrorThrown:" + errorThrown
                    );
                }
            })

            _showMessage.showDebugMessage("调用本地“置闲”接口结束");
        }

        /*
        * 置忙处理
        */
        this.doNotReady = function (callback) {

            jQuery.ajax({
                type: requestType,
                url: httpServerAdressNotReady,
                dataType: "jsonp",
                jsonp: "callback",
                beforeSend: function (XMLHttpRequest) {
                    _showMessage.showDebugMessage("调用本地“置忙”接口开始");
                    _showMessage.showURLMessage("置忙地址：" + httpServerAdressNotReady);
                },
                success: function (data) {
                    _showMessage.showDebugMessage("调用本地“置忙”接口成功, Code: " + data.Code);
                    if (callback != undefined) {
                        callback(data)
                    }
                },
                complete: function (XMLHttpRequest, textStatus) {

                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    //请求出错处理
                    _showMessage.showDebugMessage("调用本地“置忙”接口失败: \n" +
                        "XMLHttpRequest:" + XMLHttpRequest +
                        "\ntextStatus:" + textStatus +
                        "\nerrorThrown:" + errorThrown
                    );
                }
            })

            _showMessage.showDebugMessage("调用本地“置忙”接口结束");
        }

        /*
        * 保持处理
        */
        this.doHold = function (callback) {
            jQuery.ajax({
                type: requestType,
                url: httpServerAdressHold,
                dataType: "jsonp",
                jsonp: "callback",
                beforeSend: function (XMLHttpRequest) {
                    _showMessage.showDebugMessage("调用本地“保持”接口开始");
                    _showMessage.showURLMessage("保持地址：" + httpServerAdressHold);
                },
                success: function (data) {
                    _showMessage.showDebugMessage("调用本地“保持”接口成功, Code: " + data.Code);
                    if (callback != undefined) {
                        callback(data)
                    }
                },
                complete: function (XMLHttpRequest, textStatus) {
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    //请求出错处理
                    _showMessage.showDebugMessage("调用本地“保持”接口失败: " + XMLHttpRequest.statusText);
                }
            })

            _showMessage.showDebugMessage("调用本地“保持”接口结束");
        }

        /*
        * 登出处理
        */
        this.doLogOut = function (callback) {
            jQuery.ajax({
                type: requestType,
                url: httpServerAdressLogOut,
                dataType: "jsonp",
                jsonp: "callback",
                beforeSend: function (XMLHttpRequest) {
                    _showMessage.showDebugMessage("调用本地“登出”接口开始");
                    _showMessage.showURLMessage("登出地址：" + httpServerAdressLogOut);
                },
                success: function (data) {
                    _showMessage.showDebugMessage("调用本地“登出”接口成功, Code: " + data.Code);
                    referer = "";
                    if (callback != undefined) {
                        callback(data)
                    }
                },
                complete: function (XMLHttpRequest, textStatus) {

                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    //请求出错处理
                    _showMessage.showDebugMessage("调用本地“登出”接口失败: \n" +
                        "XMLHttpRequest:" + XMLHttpRequest +
                        "\ntextStatus:" + textStatus +
                        "\nerrorThrown:" + errorThrown
                    );
                }
            })

            _showMessage.showDebugMessage("调用本地“登出”接口结束");
        }

        /*
        * 反初始化处理
        */
        this.doUnInitialize = function (callback) {

            jQuery.ajax({
                type: requestType,
                url: httpServerAdressUnInitialize,
                dataType: "jsonp",
                jsonp: "callback",
                beforeSend: function (XMLHttpRequest) {
                    _showMessage.showDebugMessage("调用本地“反初始化”接口开始");
                    _showMessage.showURLMessage("反初始化地址：" + httpServerAdressUnInitialize);
                },
                success: function (data) {
                    // ucwindows.resultCallBack("doUnInitialize", data);
                    // showDebugMessage("doUnInitialize result: " + data.Code);
                    _showMessage.showDebugMessage("调用本地“反初始化”接口成功, Code: " + data.Code);
                    if (data.Code === "0") {
                        if (callback != undefined) {
                            callback(data);
                        }
                    }
                },
                complete: function (XMLHttpRequest, textStatus) {

                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    //请求出错处理
                    _showMessage.showDebugMessage("调用本地“反初始化”接口失败: \n" +
                        "XMLHttpRequest:" + XMLHttpRequest +
                        "\ntextStatus:" + textStatus +
                        "\nerrorThrown:" + errorThrown
                    );

                }
            })

            _showMessage.showDebugMessage("调用本地“反初始化”接口结束");
        }

        /*
        * 挂断处理
        */
        this.doDisconnect = function (callback) {

            jQuery.ajax({
                type: requestType,
                url: httpServerAdressDisconnect,
                dataType: "jsonp",
                jsonp: "callback",
                beforeSend: function (XMLHttpRequest) {
                    _showMessage.showDebugMessage("调用本地“挂断”接口开始");
                    _showMessage.showURLMessage("挂断地址：" + httpServerAdressDisconnect);
                },
                success: function (data) {
                    //ucwindows.resultCallBack("doDisconnect", data);
                    _showMessage.showDebugMessage("调用本地“挂断”接口成功, Code: " + data.Code);
                    if (callback != undefined) {
                        callback(data)
                    }
                },
                complete: function (XMLHttpRequest, textStatus) {

                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    //请求出错处理
                    _showMessage.showDebugMessage("调用本地“挂断”接口失败: \n" +
                        "XMLHttpRequest:" + XMLHttpRequest +
                        "\ntextStatus:" + textStatus +
                        "\nerrorThrown:" + errorThrown
                    );
                }
            })

            _showMessage.showDebugMessage("调用本地“挂断”接口结束");
        }

        /*
        * 接听按键
        */
        this.doAnswer = function (callback) {

            jQuery.ajax({
                type: requestType,
                url: httpServerAdressAnswer,
                dataType: "jsonp",
                jsonp: "callback",
                beforeSend: function (XMLHttpRequest) {
                    _showMessage.showDebugMessage("调用本地“接听”接口开始");
                    _showMessage.showURLMessage("接听地址: " + httpServerAdressAnswer);
                },
                success: function (data) {
                    //ucwindows.resultCallBack("doAnswer", data);
                    _showMessage.showDebugMessage("调用本地“接听”接口成功, Code: " + data.Code);
                    if (callback != undefined) {
                        callback(data)
                    }
                },
                complete: function (XMLHttpRequest, textStatus) {
                    // showDebugMessage("complete Start..................");
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    //请求出错处理
                    _showMessage.showDebugMessage("调用本地“接听”接口失败: \n" +
                        "XMLHttpRequest:" + XMLHttpRequest +
                        "\ntextStatus:" + textStatus +
                        "\nerrorThrown:" + errorThrown
                    );
                }
            })

            _showMessage.showDebugMessage("调用本地“接听”接口结束");
        }

        /*
        * 接回处理
        */
        this.doRetrive = function (callback) {

            jQuery.ajax({
                type: requestType,
                url: httpServerAdressRetrive,
                dataType: "jsonp",
                jsonp: "callback",
                beforeSend: function (XMLHttpRequest) {
                    _showMessage.showDebugMessage("调用本地“接回”接口开始");
                    _showMessage.showURLMessage("接回地址: " + httpServerAdressRetrive);
                },
                success: function (data) {
                    _showMessage.showDebugMessage("调用本地“接回”接口成功, Code: " + data.Code);
                    if (callback != undefined) {
                        callback(data)
                    }
                },
                complete: function (XMLHttpRequest, textStatus) {

                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    //请求出错处理
                    _showMessage.showDebugMessage("调用本地“接回”接口失败: \n" +
                        "XMLHttpRequest:" + XMLHttpRequest +
                        "\ntextStatus:" + textStatus +
                        "\nerrorThrown:" + errorThrown
                    );
                }
            })

            _showMessage.showDebugMessage("调用本地“接回”接口结束");
        }

        /*
        * 获取人员列表
        */
        this.doGetAgent = function (showType, callback) {
            var GetAgentURL = httpServerAdressGetAgent + "&showType=" + showType;
            jQuery.ajax({
                type: requestType,
                url: GetAgentURL,
                dataType: "jsonp",
                jsonp: "callback",
                beforeSend: function (XMLHttpRequest) {
                    _showMessage.showDebugMessage("调用本地“获取人员列表”接口开始");
                    _showMessage.showURLMessage("获取人员列表地址：" + GetAgentURL);
                },
                success: function (data) {
                    //ucwindows.resultCallBack("doGetAgent", data);
                    _showMessage.showDebugMessage("调用本地“获取人员列表”接口成功,Code: " + data.Code);
                    if (callback != undefined) {
                        callback(data)
                    }
                },
                complete: function (XMLHttpRequest, textStatus) {

                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    //请求出错处理
                    _showMessage.showDebugMessage("调用本地“获取人员列表”接口失败: \n" +
                        "XMLHttpRequest:" + XMLHttpRequest +
                        "\ntextStatus:" + textStatus +
                        "\nerrorThrown:" + errorThrown
                    );
                }
            })

            _showMessage.showDebugMessage("调用本地“获取人员列表”接口结束");
        }

        /*
        *咨询处理
        */
        this.doConsulting = function (consultType, targetNum, showANI, callback) {
            var _showANI = showANI == undefined ? "" : showANI;
            var Consultingurl = httpServerAdressConsulting + "consultType=" + consultType + "&targetDN=" + targetNum + "&showANI=" + _showANI;
            jQuery.ajax({
                type: requestType,
                url: Consultingurl,
                dataType: "jsonp",
                jsonp: "callback",
                beforeSend: function (XMLHttpRequest) {
                    _showMessage.showDebugMessage("调用本地“咨询”接口开始");
                    _showMessage.showURLMessage("咨询接口地址：" + Consultingurl);
                },
                success: function (data) {
                    //ucwindows.resultCallBack("doConsulting", data);
                    _showMessage.showDebugMessage("调用本地“咨询”接口成功,Code: " + data.Code);
                    if (callback != undefined) {
                        callback(data)
                    }
                },
                complete: function (XMLHttpRequest, textStatus) {

                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    //请求出错处理
                    _showMessage.showDebugMessage("调用本地“咨询”接口失败: \n" +
                        "XMLHttpRequest:" + XMLHttpRequest +
                        "\ntextStatus:" + textStatus +
                        "\nerrorThrown:" + errorThrown
                    );
                }
            })

            _showMessage.showDebugMessage("调用本地“咨询”接口结束");
        }

        /*
        *转移处理
        *
        */
        this.doAdressShift = function (callback) {
            var Consultingurl = httpServerAdressShift;
            jQuery.ajax({
                type: requestType,
                url: Consultingurl,
                dataType: "jsonp",
                jsonp: "callback",
                beforeSend: function (XMLHttpRequest) {
                    _showMessage.showDebugMessage("调用本地“转接”接口开始");
                    _showMessage.showURLMessage("转接接口地址：" + Consultingurl);
                },
                success: function (data) {
                    //ucwindows.resultCallBack("doAdressShift", data);
                    _showMessage.showDebugMessage("调用本地“转接”接口成功,Code: " + data.Code);
                    if (callback != undefined) {
                        callback(data)
                    }
                },
                complete: function (XMLHttpRequest, textStatus) {

                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    //请求出错处理
                    _showMessage.showDebugMessage("调用本地“转接”接口失败: \n" +
                        "XMLHttpRequest:" + XMLHttpRequest +
                        "\ntextStatus:" + textStatus +
                        "\nerrorThrown:" + errorThrown
                    );
                }
            })

            _showMessage.showDebugMessage("调用本地“转接”接口结束");
        }

        /*
        *接回处理
        */
        this.doAdressRetrive = function (callback) {
            var Consultingurl = httpServerAdressRetrive;
            jQuery.ajax({
                type: requestType,
                url: Consultingurl,
                dataType: "jsonp",
                jsonp: "callback",
                beforeSend: function (XMLHttpRequest) {
                    _showMessage.showDebugMessage("调用本地“接回”接口开始");
                    _showMessage.showURLMessage("接回接口地址：" + Consultingurl);
                },
                success: function (data) {
                    //ucwindows.resultCallBack("doAdressRetrive", data);
                    _showMessage.showDebugMessage("调用本地“接回”接口成功,Code: " + data.Code);
                    if (callback != undefined) {
                        callback(data)
                    }
                },
                complete: function (XMLHttpRequest, textStatus) {

                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    //请求出错处理
                    _showMessage.showDebugMessage("调用本地“接回”接口失败: \n" +
                        "XMLHttpRequest:" + XMLHttpRequest +
                        "\ntextStatus:" + textStatus +
                        "\nerrorThrown:" + errorThrown
                    );
                }
            })

            _showMessage.showDebugMessage("调用本地“接回”接口结束");
        }

        /*
        *满意度处理
        */
        this.doSatisfaction = function (callback) {
            var Consultingurl = httpServerAdressSatisfaction;
            jQuery.ajax({
                type: requestType,
                url: Consultingurl,
                dataType: "jsonp",
                jsonp: "callback",
                beforeSend: function (XMLHttpRequest) {
                    _showMessage.showDebugMessage("调用本地“满意度”接口开始");
                    _showMessage.showURLMessage("满意度接口地址：" + Consultingurl);
                },
                success: function (data) {
                    //ucwindows.resultCallBack("doAdressRetrive", data);
                    _showMessage.showDebugMessage("调用本地“满意度”接口成功,Code: " + data.Code);
                    if (callback != undefined) {
                        callback(data)
                    }
                },
                complete: function (XMLHttpRequest, textStatus) {

                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    //请求出错处理
                    _showMessage.showDebugMessage("调用本地“满意度”接口失败: \n" +
                        "XMLHttpRequest:" + XMLHttpRequest +
                        "\ntextStatus:" + textStatus +
                        "\nerrorThrown:" + errorThrown
                    );
                }
            })

            _showMessage.showDebugMessage("调用本地“满意度”接口结束");
        }

        /*
        *强插处理
        */
        this.doInsert = function (conferenceParty,callback) {
            var Consultingurl = httpServerInsert + "&agentID=" + conferenceParty;
            jQuery.ajax({
                type: requestType,
                url: Consultingurl,
                dataType: "jsonp",
                jsonp: "callback",
                beforeSend: function (XMLHttpRequest) {
                    _showMessage.showDebugMessage("调用本地“强插”接口开始");
                    _showMessage.showURLMessage("强插接口地址：" + Consultingurl);
                },
                success: function (data) {
                    //ucwindows.resultCallBack("doAdressRetrive", data);
                    _showMessage.showDebugMessage("调用本地“强插”接口成功,Code: " + data.Code);
                    if (callback != undefined) {
                        callback(data)
                    }
                },
                complete: function (XMLHttpRequest, textStatus) {

                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    //请求出错处理
                    _showMessage.showDebugMessage("调用本地“强插”接口失败: \n" +
                        "XMLHttpRequest:" + XMLHttpRequest +
                        "\ntextStatus:" + textStatus +
                        "\nerrorThrown:" + errorThrown
                    );
                }
            })

            _showMessage.showDebugMessage("调用本地“强插”接口结束");
        }

        /*
        * 强拆处理
        */
        this.doDrop = function (targetDn, callback) {
            var Consultingurl = httpServerDrop + "&targetDn=" + targetDn;
            jQuery.ajax({
                type: requestType,
                url: Consultingurl,
                dataType: "jsonp",
                jsonp: "callback",
                beforeSend: function (XMLHttpRequest) {
                    _showMessage.showDebugMessage("调用本地“强拆”接口开始");
                    _showMessage.showURLMessage("强拆接口地址：" + Consultingurl);
                },
                success: function (data) {
                    //ucwindows.resultCallBack("doAdressRetrive", data);
                    _showMessage.showDebugMessage("调用本地“强拆”接口成功,Code: " + data.Code);
                    if (callback != undefined) {
                        callback(data)
                    }
                },
                complete: function (XMLHttpRequest, textStatus) {

                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    //请求出错处理
                    _showMessage.showDebugMessage("调用本地“强拆”接口失败: \n" +
                        "XMLHttpRequest:" + XMLHttpRequest +
                        "\ntextStatus:" + textStatus +
                        "\nerrorThrown:" + errorThrown
                    );
                }
            })

            _showMessage.showDebugMessage("调用本地“强拆”接口结束");
        }

        /*
        * 监听处理
        */
        this.doListen = function (conferenceParty,callback) {
            var Consultingurl = httpServerListen + "&agentID=" + conferenceParty;
            jQuery.ajax({
                type: requestType,
                url: Consultingurl,
                dataType: "jsonp",
                jsonp: "callback",
                beforeSend: function (XMLHttpRequest) {
                    _showMessage.showDebugMessage("调用本地“监听”接口开始");
                    _showMessage.showURLMessage("监听接口地址：" + Consultingurl);
                },
                success: function (data) {
                    _showMessage.showDebugMessage("调用本地“监听”接口成功,Code: " + data.Code);
                    if (callback != undefined) {
                        callback(data)
                    }
                },
                complete: function (XMLHttpRequest, textStatus) {

                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    //请求出错处理
                    _showMessage.showDebugMessage("调用本地“监听”接口失败: \n" +
                        "XMLHttpRequest:" + XMLHttpRequest +
                        "\ntextStatus:" + textStatus +
                        "\nerrorThrown:" + errorThrown
                    );
                }
            })

            _showMessage.showDebugMessage("调用本地“监听”接口结束");
        }

        /*
        * 获取配置文件中的配置项处理
        */
        this.doGetConfig = function (callback) {
            var Consultingurl = httpServerGetConfig;
            jQuery.ajax({
                type: requestType,
                url: Consultingurl,
                dataType: "jsonp",
                jsonp: "callback",
                beforeSend: function (XMLHttpRequest) {
                    _showMessage.showDebugMessage("调用本地“获取配置文件”接口开始");
                    _showMessage.showURLMessage("获取配置文件接口地址：" + Consultingurl);
                },
                success: function (data) {
                    _showMessage.showDebugMessage("调用本地“获取配置文件”接口成功,Code: " + data.Code);
                    if (callback != undefined) {
                        callback(data)
                    }
                },
                complete: function (XMLHttpRequest, textStatus) {

                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    //请求出错处理
                    _showMessage.showDebugMessage("调用本地“获取配置文件”接口失败: \n" +
                        "XMLHttpRequest:" + XMLHttpRequest +
                        "\ntextStatus:" + textStatus +
                        "\nerrorThrown:" + errorThrown
                    );
                }
            })

            _showMessage.showDebugMessage("调用本地“获取配置文件”接口结束");
        }

        /*
        * 设置配置文件中的配置项处理
        */
        this.doSetConfig = function (column,callback) {
            var AccessURL = httpServerSetConfig + "?" + encodeURI(column);
            jQuery.ajax({
                type: requestType,
                url: AccessURL,
                dataType: "jsonp",
                jsonp: "callback",
                beforeSend: function (XMLHttpRequest) {
                    _showMessage.showDebugMessage("调用本地“获取配置文件”接口开始");
                    _showMessage.showURLMessage("获取配置文件接口地址：" + AccessURL);
                },
                success: function (data) {
                    _showMessage.showDebugMessage("调用本地“获取配置文件”接口成功,Code: " + data.Code);
                    if (callback != undefined) {
                        callback(data)
                    }
                },
                complete: function (XMLHttpRequest, textStatus) {

                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    //请求出错处理
                    _showMessage.showDebugMessage("调用本地“获取配置文件”接口失败: \n" +
                        "XMLHttpRequest:" + XMLHttpRequest +
                        "\ntextStatus:" + textStatus +
                        "\nerrorThrown:" + errorThrown
                    );
                }
            })

            _showMessage.showDebugMessage("调用本地“获取配置文件”接口结束");
        }

        /*
        * 会议处理
        */
        this.doMeeting = function (callback) {

            jQuery.ajax({
                type: requestType,
                url: httpServerAdressMeeting,
                dataType: "jsonp",
                jsonp: "callback",
                beforeSend: function (XMLHttpRequest) {
                    _showMessage.showDebugMessage("调用本地“会议”接口开始");
                    _showMessage.showURLMessage(httpServerAdressMeeting);
                },
                success: function (data) {
                    _showMessage.showDebugMessage("调用本地“会议”接口成功, Code: " + data.Code);
                    if (callback != undefined) {
                        callback(data)
                    }
                },
                complete: function (XMLHttpRequest, textStatus) {

                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    //请求出错处理
                    _showMessage.showDebugMessage("调用本地“会议”接口失败：\n" +
                        "XMLHttpRequest:" + XMLHttpRequest +
                        "\ntextStatus:" + textStatus +
                        "\nerrorThrown:" + errorThrown)
                }
            })

            _showMessage.showDebugMessage("调用本地“会议”接口结束");
        }

        /*
        * 发送按键
        */
        this.SendDTMF = function (num, callback) {
            num = num == "#" ? "%23" : num;
            var AccessURL = httpServerSendDTMF + "key=" + num;
            jQuery.ajax({
                type: requestType,
                url: AccessURL,
                dataType: "jsonp",
                jsonp: "callback",
                beforeSend: function (XMLHttpRequest) {
                    _showMessage.showDebugMessage("调用本地“发送按键”接口开始");
                    _showMessage.showURLMessage(AccessURL);
                },
                success: function (data) {
                    _showMessage.showDebugMessage("调用本地“发送按键”接口成功, Code: " + data.Code);
                    if (callback != undefined) {
                        callback(data)
                    }
                },
                complete: function (XMLHttpRequest, textStatus) {

                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    //请求出错处理
                    _showMessage.showDebugMessage("调用本地“发送按键”接口失败：\n" +
                        "XMLHttpRequest:" + XMLHttpRequest +
                        "\ntextStatus:" + textStatus +
                        "\nerrorThrown:" + errorThrown)
                }
            })
            _showMessage.showDebugMessage("调用本地“发送按键”接口结束");
        }

        /*
        * 获取坐席状态
        */
        this.GetAgentState = function (callback) {
            var msg;
            jQuery.ajax({
                type: requestType,
                url: httpServerGetAgentState,
                dataType: "jsonp",
                jsonp: "callback",
                beforeSend: function (XMLHttpRequest) {
                    _showMessage.showDebugMessage("调用本地“获取坐席状态”接口开始");
                    _showMessage.showURLMessage(httpServerGetAgentState);
                },
                success: function (data) {
                    _showMessage.showDebugMessage("调用本地“获取坐席状态”接口成功, Code: " + data.Code);
                    if(callback!=undefined && typeof callback === 'function')
                    {
                        callback(data);
                    }
                    // 处理结果
                },
                complete: function (XMLHttpRequest, textStatus) {

                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    //请求出错处理
                    _showMessage.showDebugMessage("调用本地“获取坐席状态”接口失败：\n" +
                        "XMLHttpRequest:" + XMLHttpRequest +
                        "\ntextStatus:" + textStatus +
                        "\nerrorThrown:" + errorThrown)
                }
            })
            return msg;
        }

        /*
        * 会议强拆坐席
        */
        this.doHeadoff = function (targetDn,callback) {
            var AccessURL = httpServerHeadoff + "targetDn=" + targetDn + "&callback=?";
            jQuery.ajax({
                type: requestType,
                url: AccessURL,
                dataType: "jsonp",
                jsonp: "callback",
                beforeSend: function (XMLHttpRequest) {
                    _showMessage.showDebugMessage("调用本地“会议强拆坐席”接口开始");
                    _showMessage.showURLMessage(AccessURL);
                },
                success: function (data) {
                    _showMessage.showDebugMessage("调用本地“会议强拆坐席”接口成功, Code: " + data.Code);
                    if (callback != undefined) {
                        callback(data)
                    }
                },
                complete: function (XMLHttpRequest, textStatus) {

                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    //请求出错处理
                    _showMessage.showDebugMessage("调用本地“会议强拆坐席”接口失败：\n" +
                        "XMLHttpRequest:" + XMLHttpRequest +
                        "\ntextStatus:" + textStatus +
                        "\nerrorThrown:" + errorThrown)
                }
            })
            _showMessage.showDebugMessage("调用本地“会议强拆坐席”接口结束");
        }

        /*
        * 设置其他业务系统获取事件识别码
        */
        this.doSetPageIndex = function (pageIndex, callback) {
            var AccessURL = httpServerSetPageIndex + "pageIndex=" + pageIndex + "&callback=?";
            jQuery.ajax({
                type: requestType,
                url: AccessURL,
                dataType: "jsonp",
                jsonp: "callback",
                beforeSend: function (XMLHttpRequest) {
                    _showMessage.showDebugMessage("调用本地“设置其他业务系统获取事件识别码”接口开始");
                    _showMessage.showURLMessage(AccessURL);
                },
                success: function (data) {
                    _showMessage.showDebugMessage("调用本地“设置其他业务系统获取事件识别码”接口成功, Code: " + data.Code);
                    referer = pageIndex;
                    if (callback != undefined) {
                        callback(data)
                    }
                },
                complete: function (XMLHttpRequest, textStatus) {

                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    //请求出错处理
                    _showMessage.showDebugMessage("调用本地“设置其他业务系统获取事件识别码”接口失败：\n" +
                        "XMLHttpRequest:" + XMLHttpRequest +
                        "\ntextStatus:" + textStatus +
                        "\nerrorThrown:" + errorThrown)
                }
            })
            _showMessage.showDebugMessage("调用本地“设置其他业务系统获取事件识别码”接口结束");
        }

        /*
        * 获取坐席登录信息
        */
        this.doGetAgentLoginInfo = function (callback) {
            var AccessURL = httpServerGetAgentLoginInfo + "&callback=?";
            jQuery.ajax({
                type: requestType,
                url: AccessURL,
                dataType: "jsonp",
                jsonp: "callback",
                beforeSend: function (XMLHttpRequest) {
                    _showMessage.showDebugMessage("调用本地“获取坐席登录信息”接口开始");
                    _showMessage.showURLMessage(AccessURL);
                },
                success: function (data) {
                    _showMessage.showDebugMessage("调用本地“获取坐席登录信息”接口成功, Code: " + data.Code);
                    if (callback != undefined) {
                        callback(data)
                    }
                },
                complete: function (XMLHttpRequest, textStatus) {

                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    //请求出错处理
                    _showMessage.showDebugMessage("调用本地“获取坐席登录信息”接口失败：\n" +
                        "XMLHttpRequest:" + XMLHttpRequest +
                        "\ntextStatus:" + textStatus +
                        "\nerrorThrown:" + errorThrown)
                }
            })
            _showMessage.showDebugMessage("调用本地“获取坐席登录信息”接口结束");
        }

        /*
        * 获取坐席登录信息
        */
        this.doGetShowANI = function (callback) {
            var AccessURL = httpServerGetShowANI + "&callback=?";
            jQuery.ajax({
                type: requestType,
                url: AccessURL,
                dataType: "jsonp",
                jsonp: "callback",
                beforeSend: function (XMLHttpRequest) {
                    _showMessage.showDebugMessage("调用本地“获取坐席登录信息”接口开始");
                    _showMessage.showURLMessage(AccessURL);
                },
                success: function (data) {
                    _showMessage.showDebugMessage("调用本地“获取坐席登录信息”接口成功, Code: " + data.Code);
                    if (callback != undefined) {
                        callback(data)
                    }
                },
                complete: function (XMLHttpRequest, textStatus) {

                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    //请求出错处理
                    _showMessage.showDebugMessage("调用本地“获取坐席登录信息”接口失败：\n" +
                        "XMLHttpRequest:" + XMLHttpRequest +
                        "\ntextStatus:" + textStatus +
                        "\nerrorThrown:" + errorThrown)
                }
            })
            _showMessage.showDebugMessage("调用本地“获取坐席登录信息”接口结束");
        }

        /*
        * 获取通时通次
        */
        this.doGetCallInfo = function (callback) {
            var AccessURL = httpServerGetCallReport + "&callback=?";
            jQuery.ajax({
                type: requestType,
                url: AccessURL,
                dataType: "jsonp",
                jsonp: "callback",
                beforeSend: function (XMLHttpRequest) {
                    _showMessage.showDebugMessage("调用本地“获取通时通次”接口开始");
                    _showMessage.showURLMessage(AccessURL);
                },
                success: function (data) {
                    _showMessage.showDebugMessage("调用本地“获取通时通次”接口成功, Code: " + data.Code);
                    if (callback != undefined) {
                        callback(data)
                    }
                },
                complete: function (XMLHttpRequest, textStatus) {

                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    //请求出错处理
                    _showMessage.showDebugMessage("调用本地“获取通时通次”接口失败：\n" +
                        "XMLHttpRequest:" + XMLHttpRequest +
                        "\ntextStatus:" + textStatus +
                        "\nerrorThrown:" + errorThrown)
                }
            })
            _showMessage.showDebugMessage("调用本地“获取通时通次”接口结束");
        }

        /*
        * 获取号码归属地
        */
        this.doGetNumBelong = function (ANI, callback) {
            var AccessURL = httpServerGetNumBelong + "ANI=" + ANI + "&callback=?";
            jQuery.ajax({
                type: requestType,
                url: AccessURL,
                dataType: "jsonp",
                jsonp: "callback",
                beforeSend: function (XMLHttpRequest) {
                    _showMessage.showDebugMessage("调用本地“获取号码归属地”接口开始");
                    _showMessage.showURLMessage(AccessURL);
                },
                success: function (data) {
                    _showMessage.showDebugMessage("调用本地“获取号码归属地”接口成功, Code: " + data.Code);
                    if (callback != undefined) {
                        callback(data)
                    }
                },
                complete: function (XMLHttpRequest, textStatus) {

                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    //请求出错处理
                    _showMessage.showDebugMessage("调用本地“获取号码归属地”接口失败：\n" +
                        "XMLHttpRequest:" + XMLHttpRequest +
                        "\ntextStatus:" + textStatus +
                        "\nerrorThrown:" + errorThrown)
                }
            })
            _showMessage.showDebugMessage("调用本地“获取号码归属地”接口结束");
        }

        /*
        * 坐席协作接口
        */
        this.doAssistIVRServicer = function (callback) {
            var AccessURL = httpServerAdressAgentCooperation + "&callback=?";
            jQuery.ajax({
                type: requestType,
                url: AccessURL,
                dataType: "jsonp",
                jsonp: "callback",
                beforeSend: function (XMLHttpRequest) {
                    _showMessage.showDebugMessage("调用本地“坐席协作接口”接口开始");
                    _showMessage.showURLMessage(AccessURL);
                },
                success: function (data) {
                    _showMessage.showDebugMessage("调用本地“坐席协作接口”接口成功, Code: " + data.Code);
                    if (callback != undefined) {
                        callback(data)
                    }
                },
                complete: function (XMLHttpRequest, textStatus) {

                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    //请求出错处理
                    _showMessage.showDebugMessage("调用本地“坐席协作接口”接口失败：\n" +
                        "XMLHttpRequest:" + XMLHttpRequest +
                        "\ntextStatus:" + textStatus +
                        "\nerrorThrown:" + errorThrown)
                }
            })
            _showMessage.showDebugMessage("调用本地“坐席协作接口”接口结束");
        }
        /*
        * 转IVR
        */
        this.doToIVR = function (IVRString,callback) {

            var makeCallType = "&makecallType=4";
            var callOutUrl = httpServerAdressCallOut + makeCallType + "&type=1&IVRString="+IVRString+"&callback=?";
            var msg = "";
            jQuery.ajax({
                type: requestType,
                url: callOutUrl,
                dataType: "jsonp",
                jsonp: "callback",
                beforeSend: function (XMLHttpRequest) {
                    _showMessage.showDebugMessage("调用本地“转IVR”接口开始");
                    _showMessage.showURLMessage("转IVR地址：" + callOutUrl);
                },
                success: function (data) {
                //ucwindows.resultCallBack("doLogOut", data);
                    _showMessage.showDebugMessage("调用本地“转IVR”接口成功, Code: " + data.Code);
                    if (callback!=undefined) {
                        callback(data);
                    }
                },
                complete: function (XMLHttpRequest, textStatus) {

                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                //请求出错处理
                    _showMessage.showDebugMessage("调用本地“转IVR”接口失败 : \n" +
                        "XMLHttpRequest:" + XMLHttpRequest +
                        "\ntextStatus:" + textStatus +
                        "\nerrorThrown:" + errorThrown
                    );
                }
            })
            _showMessage.showDebugMessage("调用本地“转IVR”接口结束");
            return msg;
        }

      /*
      * 密语
      */
      this.doWhisper = function(callback)
      {
        var AccessURL = httpServerAdressWhisper;
        jQuery.ajax({
          type:requestType,
          url:AccessURL,
          dataType:"jsonp",
          jsonp:"callback",
          beforeSend: function (XMLHttpRequest) {
            _showMessage.showDebugMessage("调用本地“密语”接口开始");
            _showMessage.showURLMessage(AccessURL);
          },
          success: function (data) {
            _showMessage.showDebugMessage("调用本地“密语”接口成功, Code: " + data.Code);
            if (callback != undefined) {
              callback(data)
            }
          },
          complete: function (XMLHttpRequest, textStatus) {
          },
          error: function (XMLHttpRequest, textStatus, errorThrown) {
//请求出错处理
            _showMessage.showDebugMessage("调用本地“密语”接口失败：\n" +
              "XMLHttpRequest:" + XMLHttpRequest +
              "\ntextStatus:" + textStatus +
              "\nerrorThrown:" + errorThrown)
          }
        })
      }


        /*
        * 转IVR
        */
        this.doToIVR = function(IVRData,callback)
        {
            var AccessURL = httpServerAdressToIVR+"Ivrdata="+IVRData;
            jQuery.ajax({
                type:requestType,
                url:AccessURL,
                dataType:"jsonp",
                jsonp:"callback",
                beforeSend: function (XMLHttpRequest) {
                    _showMessage.showDebugMessage("调用本地“转IVR”接口开始");
                    _showMessage.showURLMessage(AccessURL);
                },
                success: function (data) {
                    _showMessage.showDebugMessage("调用本地“转IVR”接口成功, Code: " + data.Code);
                    if (callback != undefined) {
                        callback(data)
                    }
                },
                complete: function (XMLHttpRequest, textStatus) {

                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    //请求出错处理
                    _showMessage.showDebugMessage("调用本地“转IVR”接口失败：\n" +
                        "XMLHttpRequest:" + XMLHttpRequest +
                        "\ntextStatus:" + textStatus +
                        "\nerrorThrown:" + errorThrown)
                }
            })
        }

        /*
        * 获取技能组列表
        */
        this.doGetSkillList = function(callback)
        {
            var AccessURL = httpServerAdressGetSkillList;
            jQuery.ajax({
                type: requestType,
                url: AccessURL,
                dataType: "jsonp",
                jsonp: "callback",
                beforeSend: function (XMLHttpRequest) {
                    _showMessage.showDebugMessage("调用本地“获取技能组列表”接口开始");
                    _showMessage.showURLMessage(AccessURL);
                },
                success: function (data) {

                    _showMessage.showDebugMessage("调用本地“获取技能组列表”接口成功, Code: " + data.Code);
                    if (callback != undefined) {
                        callback(data)
                    }
                },
                complete: function (XMLHttpRequest, textStatus) {

                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    //请求出错处理
                    _showMessage.showDebugMessage("调用本地“获取技能组列表”接口失败：\n" +
                        "XMLHttpRequest:" + XMLHttpRequest +
                        "\ntextStatus:" + textStatus +
                        "\nerrorThrown:" + errorThrown)
                }
            })
        }
        
       /*
        * 转接技能组
        */
        this.doTransferSkill = function(skillName,callback)
        {
            var AccessURL = httpServerAdressTransferSkill + "skillName=" + skillName;
            jQuery.ajax({
                type: requestType,
                url: AccessURL,
                dataType: "jsonp",
                jsonp: "callback",
                beforeSend: function (XMLHttpRequest) {
                    _showMessage.showDebugMessage("调用本地“转接技能组”接口开始");
                    _showMessage.showURLMessage(AccessURL);
                },
                success: function (data) {

                    _showMessage.showDebugMessage("调用本地“转接技能组”接口成功, Code: " + data.Code);
                    if (callback != undefined) {
                        callback(data)
                    }
                },
                complete: function (XMLHttpRequest, textStatus) {

                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    //请求出错处理
                    _showMessage.showDebugMessage("调用本地“转接技能组”接口失败：\n" +
                        "XMLHttpRequest:" + XMLHttpRequest +
                        "\ntextStatus:" + textStatus +
                        "\nerrorThrown:" + errorThrown)
                }
            })
        }

       /* 
        * 单步会议
        */
        this.doStepMeeting = function(consultType, targetNum, showANI, callback)
        {
            console.log('uc js start doStepMeeting');
            thirdcode = '1';
            doConsulting(consultType, targetNum, showANI, callback);
        }

        /*
         * 静音，取消静音
         */
        this.doSetMicMute = function(mute,callback)
        {
            var AccessURL = httpServerAdressSetMicMute + "mute=" + mute;
            jQuery.ajax({
                type: requestType,
                url: AccessURL,
                dataType: "jsonp",
                jsonp: "callback",
                beforeSend: function (XMLHttpRequest) {
                    _showMessage.showDebugMessage("调用本地“静音”接口开始");
                    _showMessage.showURLMessage(AccessURL);
                },
                success: function (data) {

                    _showMessage.showDebugMessage("调用本地“静音”接口成功, Code: " + data.Code);
                    if (callback != undefined) {
                        callback(data)
                    }
                },
                complete: function (XMLHttpRequest, textStatus) {

                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    //请求出错处理
                    _showMessage.showDebugMessage("调用本地“静音”接口失败：\n" +
                        "XMLHttpRequest:" + XMLHttpRequest +
                        "\ntextStatus:" + textStatus +
                        "\nerrorThrown:" + errorThrown)
                }
            })
        }

        /*
        * 获取随路数据
        */
        this.doGetAssociateData = function (callback) {
            var AccessURL = httpServerGetAssociateData + "callback=?";
            jQuery.ajax({
                type: requestType,
                url: AccessURL,
                dataType: "jsonp",
                jsonp: "callback",
                beforeSend: function (XMLHttpRequest) {
                    _showMessage.showDebugMessage("调用本地“获取随路数据”接口开始");
                    _showMessage.showURLMessage(AccessURL);
                },
                success: function (data) {
                    _showMessage.showDebugMessage("调用本地“获取随路数据”接口成功, Code: " + data.Code);
                    if (callback != undefined) {
                        callback(data)
                    }
                },
                complete: function (XMLHttpRequest, textStatus) {

                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    //请求出错处理
                    _showMessage.showDebugMessage("调用本地“获取随路数据”接口失败：\n" +
                        "XMLHttpRequest:" + XMLHttpRequest +
                        "\ntextStatus:" + textStatus +
                        "\nerrorThrown:" + errorThrown)
                }
            })
            _showMessage.showDebugMessage("调用本地“获取随路数据”接口结束");
        }
    }

    /*
    * 调用Query接口, 解析事件，如果为振铃事件进行弹屏处理
    */
    function getEvent(callback) {

        var eventUrl = httpServerAdress + "&index=" + m_PageIndex + "&referer=" + referer;

        jQuery.ajax({
            type: requestType,
            url: eventUrl,
            dataType: "jsonp",
            jsonp: "callback",
            scriptCharset: "UTF-8",
            beforeSend: function (XMLHttpRequest) {

            },
            success: function (data) {

                // 事件类型
                var resultCode = data.Result;

                // if (resultCode == -1) {
                // 	return;
                // } else {
                // 	_showMessage.showQueryMessage(data);
                // };
                var ani = data.ANI;
                if (ani != undefined && ani.toUpperCase().indexOf("TEL:") > -1) {
                    ani = ani.substring(4);
                }
                // 去除手机号码开头的0
                if (ani != undefined && ani.length == 12 && ani.indexOf("01") == 0) {
                    ani = ani.substring(1);
                }
                data.ANI = ani;
                if (callback != undefined) {
                    callback(data);
                }
                data.agentID = agentID;
                data.deviceID = deviceID;

                // 事件类型
                var EventType = data.EventType;
                console.log('EventType is recived:' + EventType + ' thirdcode:' + thirdcode);
                if (EventType == "AgentStatus_Consulted" && thirdcode == '1') {
                //咨询第三方接通事件
                //会议方式三方协助的全局变量为“1”，接收到该事件后，调用会议接口
                    console.log('AgentStatus_Consulted is recived');
                    var phone = window.phone;
                    phone.defineEvent('btn_meet');
                    // this.doMeeting();
                    thirdcode = '0';
                    console.log('ucjs step meeting is end.');
                }

                //if (EventType == AgentStatus_Alerting) {
                if (openWindowMode == "UC_OPEN") {
                    doOpenUrl(data);
                } else {
                    doCallBackOpen(data);
                }
                //	}
            },
            complete: function (XMLHttpRequest, textStatus) {
                // showDebugMessage("complete Start..................");
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                //请求出错处理
                // 2018-08-02 追加 请求不到UCService时返回
                if (IsIE())
                    callback(eval('(' + "{\"Result\": \"" + XMLHttpRequest.status + "\"}" + ')'))
                else
                    callback(JSON.parse("{\"Result\": \"" + XMLHttpRequest.status + "\"}"));
                // 2014-11-06 追加   请求不到UC时返回UC登出状态
                //if (XMLHttpRequest.status == 404) {
                //    doCallBackOpen(JSON.parse("{Result: \""+XMLHttpRequest.status+"\"}"));
                //}
                //data.EventType = "AgentStatus_Logout";
                //  doCallBackOpen(data);
                // 2014-11-06 追加   请求不到UC时返回UC登出状态
            }
        })

    }


// UC直接弹屏
    function doOpenUrl(events) {
        // 拼接弹屏地址
        var j = 0;
        for (j = 0; j < call_in_params.length; j++) {
            var paramName = call_in_params[j];
            if (paramName != "") {
                // 第一个参数
                if (openUrl.indexOf("?") < 0) {
                    var dataValue = "";
                    if (event_params[j] == "OrgANI") {
                        dataValue = events.OrgANI;
                    } else if (event_params[j] == "OrgDNIS") {
                        dataValue = events.OrgDNIS;
                    } else if (event_params[j] == "ANI") {
                        dataValue = events.ANI;
                    } else if (event_params[j] == "DNIS") {
                        dataValue = events.DNIS;
                    } else if (event_params[j] == "CslANI") {
                        dataValue = events.CslANI;
                    } else if (event_params[j] == "CslDNIS") {
                        dataValue = events.CslDNIS;
                    } else if (event_params[j] == "ServiceUnitType") {
                        dataValue = events.ServiceUnitType;
                    } else if (event_params[j] == "ReqSkill") {
                        dataValue = events.ReqSkill;
                    } else if (event_params[j] == "ResSkill") {
                        dataValue = events.ResSkill;
                    } else if (event_params[j] == "CallType") {
                        dataValue = events.CallType;
                    } else if (event_params[j] == "IVRData") {
                        dataValue = events.IVRData;
                    } else if (event_params[j] == "SessionID") {
                        dataValue = events.SessionID;
                    }
                    openUrl = openUrl + "?" + paramName + "=" + dataValue;
                    // 其他参数
                } else {
                    var dataValue = "";
                    if (event_params[j] == "OrgANI") {
                        dataValue = events.OrgANI;
                    } else if (event_params[j] == "OrgDNIS") {
                        dataValue = events.OrgDNIS;
                    } else if (event_params[j] == "ANI") {
                        dataValue = events.ANI;
                    } else if (event_params[j] == "DNIS") {
                        dataValue = events.DNIS;
                    } else if (event_params[j] == "CslANI") {
                        dataValue = events.CslANI;
                    } else if (event_params[j] == "CslDNIS") {
                        dataValue = events.CslDNIS;
                    } else if (event_params[j] == "ServiceUnitType") {
                        dataValue = events.ServiceUnitType;
                    } else if (event_params[j] == "ReqSkill") {
                        dataValue = events.ReqSkill;
                    } else if (event_params[j] == "ResSkill") {
                        dataValue = events.ResSkill;
                    } else if (event_params[j] == "CallType") {
                        dataValue = events.CallType;
                    } else if (event_params[j] == "IVRData") {
                        dataValue = events.IVRData;
                    } else if (event_params[j] == "SessionID") {
                        dataValue = events.SessionID;
                    }
                    openUrl = openUrl + "&" + paramName + "=" + dataValue;
                }

            }
        }
        showDebugMessage("openUrl: " + openUrl);
        window.open(openUrl);
    }

// 回调业务系统弹屏
    function doCallBackOpen(events) {
        if (!ucwindows.ucCallBack) {
            return;
        }
        if (events.EventType == "AgentStatus_Consulting" && thirdcode == '1') {
            //咨询第三方振铃事件
            //会议方式三方协助的全局变量为“1”，则将该事件的转换成AgentStatus_Held，传递给外部
            events.EventType = "AgentStatus_Held";
        } else if (events.EventType == "AgentStatus_Consulted" && thirdcode == '1') {
            //咨询第三方接通事件
            //会议方式三方协助的全局变量为“1”，接收到该事件后，调用会议接口
            //doMeeting();
        } else if (events.EventType == "AgentStatus_Connected_Normal") {
            //咨询接回或第三方挂断事件
            //接收到该事件后，将会议方式三方协助的全局变量设置为“0”
            thirdcode = 0;
        }

        ucwindows.ucCallBack(events);
    }

// 回调业务系统弹屏
    function setAgentInfo(result) {
        ucwindows.setAgentInfo(result);
    }

//输出信息
    function showMessage() {
        //打印接口调用情况
        this.showDebugMessage = function (msg) {
            if (config.DeBug) {
                console.log(msg, "       --From uc-3.0 DeBug  ");
                //console.dir(msg)
            }
        }
        //打印接口调用地址
        this.showURLMessage = function (Url) {
            if (config.ShowURL) {
                console.log(Url, "       --From uc-3.0 showURL  ");
            }
        }
        //打印Query调用情况
        this.showQueryMessage = function (Agent_Event) {
            if (config.ShowQuery) {
                console.log(Agent_Event, "       --From uc-3.0 ShowQuery  ")
            }
        }
    }
    var _showMessage = new showMessage();

// 暂停执行函数
    function Pause(obj, iMinSecond) {
        if (window.eventList == null)
            window.eventList = new Array();
        var ind = -1;
        for (var i = 0; i < window.eventList.length; i++) {
            if (window.eventList[i] == null) {
                window.eventList[i] = obj;
                ind = i;
                break;
            }
        }
        if (ind == -1) {
            ind = window.eventList.length;
            window.eventList[ind] = obj;
        }
        setTimeout("GoOn(" + ind + ")", iMinSecond);
    }

// 继续函数
    function GoOn(ind) {
        var obj = window.eventList[ind];
        window.eventList[ind] = null;
        if (obj.NextStep)
            obj.NextStep();
        else obj();
    }

// 继续函数
    function sleep(sleeptime) {
        var start = new Date().getTime();
        while (true)
            if (new Date().getTime() - start > sleeptime)
                break;
    }

    function killErrors() {
        return true;
    }

    function formatDate(d) {
        var year = d.getFullYear();
        var month = d.getMonth() + 1;
        var date = d.getDate();
        var hour = d.getHours();
        var minute = d.getMinutes();
        var second = d.getSeconds();
        month = month < 10 ? '0' + month : month;
        date = date < 10 ? '0' + date : date;
        hour = hour < 10 ? '0' + hour : hour;
        minute = minute < 10 ? '0' + minute : minute;
        second = second < 10 ? '0' + second : second;
        return year + '-' + month + '-' + date + ' ' + hour + ':' + minute + ':' + second;
    }

    function IsIE() {
        if (navigator.appName == "Microsoft Internet Explorer")
            return true;
        else
            return false;
    }

    function S4() {
        return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
    };
// Generate a pseudo-GUID by concatenating random hexadecimal.
    function guid() {
        return (S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4());
    };
    window.onerror = killErrors;
    uc305 = UCObj;
    return uc305;

}))


